package com.nexus.ai.gpt;

import com.nexus.core.properties.ExternalPropertySourceFactory;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.ai.chat.memory.MessageWindowChatMemory;
import org.springframework.ai.chat.memory.repository.jdbc.JdbcChatMemoryRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * 聊天模型配置
 *
 * @Date 2025/9/27 16:30
 * @Author luzhengning
 **/
@Configuration
@PropertySource(
        name = "gtp.properties",
        value = "classpath*:gtp-pro.properties", encoding = "UTF8",
        factory = ExternalPropertySourceFactory.class,
        ignoreResourceNotFound = true
)
public class NexusAiGptConfig {

//    /**
//     * 创建基于默认的大模型客户端
//     *
//     * @Date 2025/9/27 16:32
//     * @Author luzhengning
//     **/
//    @Bean
//    public ChatClient chatClient(ChatClient.Builder chatClientBuilder) {
//        return chatClientBuilder.build();
//    }

    /**
     * 聊天记录存储
     *
     * @Date 2025/9/27 21:48
     * @Author luzhengning
     **/
    @Bean
    public ChatMemory chatMemory(JdbcChatMemoryRepository jdbcChatMemoryRepository) {
        ChatMemory chatMemory = MessageWindowChatMemory.builder()
                .chatMemoryRepository(jdbcChatMemoryRepository)
                .maxMessages(10)
                .build();
        return chatMemory;
    }

}
